# --- 方法没有重载 ---

# 如果定义了重名方法，最后定义的生效


class Foo:
    def hi(self):
        print("你好")

    def hi(self, name):
        print("你好", name)


f = Foo()
# f.hi() # TypeError: Foo.hi() missing 1 required positional argument: 'name' 【已经被后面定义的同名方法覆盖了】
f.hi("yesen")

# --- 方法的动态性  ---


def work(self):
    print("工作")


def play(self):
    print("玩耍")


class Bar:
    def work(self):
        print("Bar在努力工作")


b1 = Bar()
b1.work()
# b1.play()

Bar.work = play
Bar.play = work

b2 = Bar()
b2.work()
b2.play()
